package org.example.redo.config;

import org.example.redo.constant.Constants;
import org.springframework.amqp.core.*;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitMqConfig {

    @Bean("workQueue")
    public Queue workQueue() {
        return QueueBuilder.durable(Constants.WORK_QUEUE).build();
    }
    @Bean("direct_queue1")
    public Queue direct_queue1() {
        return QueueBuilder.durable(Constants.DIRECT_QUEUE1).build();
    }
    @Bean("direct_queue2")
    public Queue direct_queue2() {
        return QueueBuilder.durable(Constants.DIRECT_QUEUE2).build();
    }
    @Bean("direct_exchange")
    public DirectExchange direct_exchange() {
        return ExchangeBuilder.directExchange(Constants.DIRECT_EXCHANGE).durable(true).build();
    }
    @Bean("binding1")
    public Binding binding1(@Qualifier("direct_exchange") DirectExchange direct_exchange , @Qualifier("direct_queue1") Queue queue) {
        return BindingBuilder.bind(queue).to(direct_exchange).with("a1");
    }
    @Bean("binding2")
    public Binding binding2(@Qualifier("direct_exchange") DirectExchange direct_exchange , @Qualifier("direct_queue2") Queue queue) {
        return BindingBuilder.bind(queue).to(direct_exchange).with("a2");

    }
}
